package cn.iocoder.yudao.module.common.dal.mysql.comment;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.common.dal.dataobject.comment.CommentDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.common.controller.admin.comment.vo.*;

/**
 * 评论 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CommentMapper extends BaseMapperX<CommentDO> {

    default PageResult<CommentDO> selectPage(CommentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CommentDO>()
                .eqIfPresent(CommentDO::getUserId, reqVO.getUserId())
                .eqIfPresent(CommentDO::getContent, reqVO.getContent())
                .eqIfPresent(CommentDO::getTargetId, reqVO.getTargetId())
                .eqIfPresent(CommentDO::getTargetType, reqVO.getTargetType())
                .eqIfPresent(CommentDO::getParentCommentId, reqVO.getParentCommentId())
                .eqIfPresent(CommentDO::getCommentType, reqVO.getCommentType())
                .likeIfPresent(CommentDO::getCreatorName, reqVO.getCreatorName())
                .betweenIfPresent(CommentDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(CommentDO::getUpdaterName, reqVO.getUpdaterName())
                .eqIfPresent(CommentDO::getVersion, reqVO.getVersion())
                .orderByDesc(CommentDO::getId));
    }

}